home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / system-tools-backends-2.0 / scripts / Utils / DBus.pm < prev    next >
Encoding:
Perl POD Document  |  2009-04-09  |  1.7 KB  |  67 lines

  1. #-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  
  3. # Common stuff for the ximian-setup-tools backends.
  4. #
  5. # Copyright (C) 2000-2001 Ximian, Inc.
  6. #
  7. # Authors: Hans Petter Jansson <hpj@ximian.com>
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU Library General Public License as published
  11. # by the Free Software Foundation; either version 2 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. # GNU Library General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU Library General Public License
  20. # along with this program; if not, write to the Free Software
  21. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  22.  
  23. package Utils::DBus;
  24.  
  25. use Net::DBus;
  26. use Net::DBus::Service;
  27. use Net::DBus::Reactor;
  28.  
  29. sub get_bus
  30. {
  31.   return Net::DBus->system;
  32. }
  33.  
  34. sub run
  35. {
  36.   Net::DBus::Reactor->main->run ();
  37. }
  38.  
  39. sub shutdown
  40. {
  41.   # exit the main loop
  42.   Net::DBus::Reactor->main->shutdown ();
  43. }
  44.  
  45. sub remove_timeout
  46. {
  47.   my ($timeout) = @_;
  48.   Net::DBus::Reactor->main->remove_timeout ($timeout);
  49. }
  50.  
  51. sub add_timeout
  52. {
  53.   my ($time, $func) = @_;
  54.   return Net::DBus::Reactor->main->add_timeout ($time, Net::DBus::Callback->new(method => $func));
  55. }
  56.  
  57. sub get_platform
  58. {
  59.   my $bus = Net::DBus->system;
  60.   my $service = $bus->get_service("org.freedesktop.SystemToolsBackends");
  61.   my $obj = $service->get_object ("/org/freedesktop/SystemToolsBackends/Platform");
  62.  
  63.   return $obj->getPlatform ();
  64. }
  65.  
  66. 1;
  67.